#include <iostream>
#include <stdio.h>

using namespace std;

#define MAX 100

int main()
{
  int ncase = 1;
  int n,m;
  int field[MAX][MAX];
  int res;
  char temp;
  int primeravez = 1;
  
  while(true)
  {
    cin>>n>>m;
    
    if(n==0) break;
    
    if(primeravez) primeravez=0;
    else cout<<endl;
    
    scanf("%c", &temp);
    
    for(int i=0; i<n; i++)
      for(int j=0; j<=m; j++)
      {
        scanf("%c", &temp);
        if(temp == '.')
          field[i][j]=0;
        else if(temp == '*')
          field[i][j]=1;
      }
    /*
    for(int i=0; i<n; i++)
    {
      for(int j=0; j<m; j++)
      {
        cout<<field[i][j];
      }
      cout<<endl;
    }
    */
    
    cout<<"Field #"<<(ncase++)<<":"<<endl;
    for(int i=0; i<n; i++)
      for(int j=0; j<=m; j++)
      {
        if(j==m){ cout<<endl; continue; }
        if(field[i][j] == 1){ cout<<'*'; continue; }
        res = 0;
        if(i-1 >= 0             && field[i-1][j]   == 1)   res++;
        if(i-1 >= 0 && j-1 >= 0 && field[i-1][j-1] == 1)   res++;
        if(            j-1 >= 0 && field[i]  [j-1] == 1)   res++;
        if(i+1 < n  && j-1 >= 0 && field[i+1][j-1] == 1)   res++;
        if(i+1 < n              && field[i+1][j]   == 1)   res++;
        if(i+1 < n  && j+1 < m  && field[i+1][j+1] == 1)   res++;
        if(            j+1 < m  && field[i]  [j+1] == 1)   res++;
        if(i-1 >= 0 && j+1 < m  && field[i-1][j+1] == 1)   res++;
        cout<<res;
      }
  }
  
  return 0;
}
